const formatTime = date => {
  const year = date.getFullYear()
  const month = date.getMonth() + 1
  const day = date.getDate()
  const hour = date.getHours()
  const minute = date.getMinutes()
  const second = date.getSeconds()
  return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
}
const app = getApp();
//const user = JSON.parse(wx.getStorageSync("user"));
const base_url = app.globalData.base_url;
const formatNumber = n => {
  n = n.toString()
  return n[1] ? n : '0' + n
}

const zan = function (data, callback) {
  wx.request({
    url: base_url + '/Post/zan',
    data: data,
    method: 'POST',
    header: {
      'content-type': 'application/x-www-form-urlencoded'
    },
    success: res => {
      if (res.data.success == '1') {
        callback(res.data)
      } else {

      }
    }
  })
}
const zero = function(n){
  return n<10? '0'+ n : n
}
module.exports = {
  formatTime: formatTime,
  zan:zan,
  zero:zero
}

